import xlrd
class read_excel():
    def excel_login(self,path,dates):
        book = xlrd.open_workbook(path)  ## 读取Excel
        sheet = book.sheets()      ## 文件中所有的sheet
        num = sheet[dates-1]     ## 选择第几个sheet
        nrow = num.nrows           ## 返回表中有多少行
        # print(type(nrow))   #3
        ncols =  num.ncols         ## 返回表中的列
        # print(ncols)   #5
        li = []
        for i in range(1,nrow):     #在行中
            dict = {}
            for j in range(ncols):  #在列中
                key_name  = num.cell(0,j).value
                key_value = num.cell(i,j).value
                # print(key_name,key_value)
                dict[key_name] = key_value
            li.append(dict)
        return li

if __name__ == '__main__':
    a = read_excel()
    data=a.excel_login(r"dates.xlsx",1)
    print(data)